package com.cobra.activiti.enums;
import lombok.Getter;

/**
 * @author yaobin
 * @date 2020/4/20 0020 14:43
 * @Description 结果枚举类
 */
@Getter
public enum ResultEnum {
    SUCCESS("101", "成功"),
    FAILURE("102", "失败"),
    USER_NEED_AUTHORITIES("201", "用户未登录"),
    USER_LOGIN_FAILED("202", "用户账号或密码错误"),
    USER_LOGIN_SUCCESS("203", "用户登录成功"),
    USER_NO_ACCESS("204", "用户无权访问"),
    USER_LOGOUT_SUCCESS("205", "用户登出成功"),
    TOKEN_IS_BLACKLIST("206", "此token为黑名单"),
    LOGIN_IS_OVERDUE("207", "登录已失效");
    public String code;
    public String message;

    ResultEnum(String code, String message) {
               this.code = code;
        this.message = message;
    }

    public static ResultEnum parse(String code) {
        ResultEnum[] values = values();
        for (ResultEnum value : values) {
            if (value.getCode() == code) {
                return value;
            }
        }
        throw new RuntimeException("Unknown code of ResultEnum");
    }
}